#!/bin/sh
set -e
BUILD="$(pwd)"
newline="
"

if test -f "$BUILD"/x264_options ; then
    IFS=$newline
    set -- $(cat "$BUILD"/x264_options) "$@"
    unset -v IFS
fi

OPTIONS="--enable-shared --enable-pic"

case "$PKG_CONFIG_PATH" in
  '')
    export PKG_CONFIG_PATH="$BUILD/build_libs/lib/pkgconfig"
    ;;
  *)
    export PKG_CONFIG_PATH="$BUILD/build_libs/lib/pkgconfig:$PKG_CONFIG_PATH"
    ;;
esac

cd "$BUILD"/x264
./configure  --prefix="$BUILD/build_libs" --libdir="$BUILD/build_libs/lib" $OPTIONS "$@"
